Right, I had to get up to speed again, but it's done.
Here's all the code you need.
First the CASE:
CASE "!5":
Globalvar $Seconds;
Globalvar $DisplaySeconds;
Globalvar $Minutes;
Globalvar $start_race_seconds;
$Seconds = 0;
$DisplaySeconds = 0;
$Minutes = 0;
$start_race_seconds = 300;
calc_race_start_time( 0,0 );
BREAK;
Then the sub-event to calculate the time:
Sub calc_race_start_time( $KeyFlags,$id )
$Minutes = round(($start_race_seconds/60),0);
$Time = (round(($start_race_seconds/60),2)-$Minutes);
$Seconds = round(($Time*60),0);
IF ( $Seconds < 0 )
THEN # when seconds are negative
$Minutes = $Minutes-1;
$Seconds = 60 + $Seconds;
ENDIF
$DisplaySeconds=$Seconds;
Timer( $KeyFlags );#Goto Countdowntimer
EndSub
Then the actual button to display the time:
Sub Timer( $KeyFlags )
### Display button ###
openGlobalButton( "countdown_button",78,60,82,20,13,-1,16,"^3Race starts in " . $Minutes . " minutes and " . $DisplaySeconds . " seconds" );
### End ###
### Reduce seconds by 1 ###
### If seconds are below 0, reduce minutes by 1 and set seconds back to 59 ###
### If seconds are below 10, add a leading 0 to the displayed value ####
$Seconds = $Seconds-1;
IF ( $Seconds < 0 )
THEN
$Minutes = $Minutes-1;
$Seconds = 59;
ENDIF
IF ( $Seconds < 10 )
THEN
$DisplaySeconds="0".$Seconds;
ELSE
$DisplaySeconds=$Seconds;
ENDIF
### End ###
### If minutes and seconds are greater then or equal to 0, use the 1 second loop, else close button ###
IF ( $Minutes >= 0 && $Seconds >=0 )
THEN
HostDelayedCommand( 1, Timer );
ELSE
closeGlobalButton( "countdown_button" );
ENDIF
### End ###
EndSub